package TestSparkConversionOperator;

import org.apache.spark.SparkConf;
import org.apache.spark.api.java.JavaRDD;
import org.apache.spark.api.java.JavaSparkContext;

import java.util.List;

public class SparkTake {
    /**
     * Action算子之take
     *take返回指定的前N个数据
     * @param args
     */
    public static void main(String[] args) {
        SparkConf sparkConf = new SparkConf().setAppName("spark demo").setMaster(args[0]);
        JavaSparkContext sc = new JavaSparkContext(sparkConf);
        JavaRDD<String> rdd = sc.textFile("G:\\桌面\\文本\\fsdfj.txt");

        List<String> res = rdd.take(2);
        for (String s : res){
            System.out.println(s);
        }
    }
}
